package ex;

import java.util.PriorityQueue;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-9-7下午 06:12
 */
public class 大根堆 {
    public static void main(String[] args) {

        int[] arr = new int[100];
        PriorityQueue<Integer> pq = new PriorityQueue<>((v1, v2) -> (v2 - v1));
        for (int num : arr) {
            if (pq.size() < 2) {
                pq.offer(num);
            } else if (num < pq.peek()) {
                pq.poll();
                pq.offer(num);
            }
        }

    }
}
